<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Object.create()与__proto__</title>
</head>
<body>
    <script>
        let hd = {
            show(){
                console.log(this.name);
            }
        };


        // Object.create()只能定义对象的原型但不能获取
        // 方法一：
        // let hdms = Object.create(hd);
        // hdms.name = "hdms";
        // 方法二：
        let hdms = Object.create(hd,{
            name:{
                value:"hd"
            }
        });
        console.log(hdms);
        hdms.show();


        // __proto__既能定义对象的原型，又能获取对象的原型
        let xiasnn = {name:"xiasnn"};
        xiasnn.__proto__ = hd;
        console.log(xiasnn);
        xiasnn.show();
        console.log(xiasnn.__proto__);
    </script>
</body>
</html>